package com.ufm.util;

import java.util.ArrayList;
import java.util.List;


public class PageUtil{
	
	/**
	 * 默认每页显示10条记录
	 */
	public static final Integer RECORD_NUM = 10;
	/**
	 * 默认当前页
	 */
	public static final Integer PAGE_NUM = 1;
	
	public static List getPageList(List sourceList, int currentPageNo, int perPageNumber){
		List resultList = new ArrayList();
		if(perPageNumber >= sourceList.size()){
			for(int i = 0; i < sourceList.size(); i++){
				resultList.add(sourceList.get(i));
			}
		}else if(perPageNumber*currentPageNo >= sourceList.size()){
			for(int i = (currentPageNo-1)*perPageNumber; i < sourceList.size(); i++){
				resultList.add(sourceList.get(i));
			}
		}else{
			for(int i = (currentPageNo-1)*perPageNumber; i < currentPageNo*perPageNumber; i++){
				resultList.add(sourceList.get(i));
			}
		}
		return resultList;
	}
}